<!-- Veljko Jovanovic -->
<?php
session_start();

include("konekcija_sa_bazom.php");

mysql_query("SET NAMES utf8");


$idkor=$_POST['idKor'];

$querry = "SELECT idTipLicnosti FROM posetilac WHERE idKorisnik = '$idkor';";

$result = mysql_query($querry);
$row = mysql_fetch_row($result);

if (isset($_POST['plus']))
{
	$id = $_POST['plus'];
	$querry = "UPDATE poklon
SET brojPluseva = brojPluseva + 1
WHERE idPoklon='$id';";
	mysql_query($querry);
if (isset($row[0]))
{
	$tipLicnosti = $row[0];
	$querry="SELECT * FROM odgovara WHERE idTipLicnosti = $tipLicnosti AND idPoklon = '$id';";
	$result=mysql_query($querry);
	if (mysql_num_rows($result) == 0)
	{
		$querry="INSERT INTO odgovara (idTipLicnosti, idPoklon, koeficijent) VALUES ('$tipLicnosti', '$id', '1');";
		mysql_query($querry);
	}
	else
	{
		$querry = "UPDATE odgovara
SET koeficijent = koeficijent + 1 WHERE
idTipLicnosti = '$tipLicnosti' AND idPoklon = '$id';";
		mysql_query($querry);
	}
}
}
else
{
	$id = $_POST['minus'];
	$querry = "UPDATE poklon
	SET brojMinusa = brojMinusa + 1
	WHERE idPoklon='$id';";
	mysql_query($querry);
	if (isset($row[0]))
{
	$tipLicnosti = $row[0];
	$querry="SELECT * FROM odgovara WHERE idTipLicnosti = '$tipLicnosti' AND idPoklon = '$id';";
	$result=mysql_query($querry);
	if (mysql_num_rows($result) == 0)
	{
		$querry="INSERT INTO odgovara (idTipLicnosti, idPoklon, koeficijent) VALUES ('$tipLicnosti', '$id', '-1');";
		mysql_query($querry);
	}
	else
	{
		$querry = "UPDATE odgovara
SET koeficijent = koeficijent - 1 WHERE
idTipLicnosti = '$tipLicnosti' AND idPoklon = '$id';";
		mysql_query($querry);
	}
}
}
$_SESSION['ocenjivao'] = $id;

mysql_query("SET NAMES utf8");




$querry="SELECT * FROM poklon WHERE idPoklon = '".$id."'";
	$result = mysql_query($querry);
	$row = mysql_fetch_array($result);

$naziv = $row['naziv'];
$cena = $row['cena'];
	$plus = $row['brojPluseva'];
	$minus = $row['brojMinusa'];
mysql_close($veza);
?>
<div class="dashes-top"></div>
            <div class="dashes-bottom"></div>
            <font size="+1">
<?php
 echo "Naziv: $naziv</br>Cena: $cena</br>";
echo '</br><center><img src="images/plus.png" alt="Plus" />'.$plus.':'.$minus.'<img src="images/minus.png" alt="Minus" /></center></font>';
?>